using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WorkTracker.BusinessObjects;

namespace WorkTracker
{
	public partial class ManageStatusChangesForm : Form
	{

		#region Properties

		private DataTable statusChangesDataTable = new DataTable();
		BindingList<StatusChange> bindingList;

		#endregion

		public ManageStatusChangesForm() {
			InitializeComponent();
			grdStatusChanges.AutoGenerateColumns = false;
			DataGridViewTextBoxColumn columnDate = new DataGridViewTextBoxColumn();
			DataGridViewComboBoxColumn columnStatus = new DataGridViewComboBoxColumn
();

			columnDate.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			columnDate.DataPropertyName = "Date";
			columnDate.HeaderText = "Date";
			columnDate.MinimumWidth = 150;
			columnDate.Name = "Date";
			columnDate.ValueType = typeof(DateTime);

			columnStatus.DataPropertyName = "Status";
			columnStatus.HeaderText = "Status";
			columnStatus.MinimumWidth = 150;
			columnStatus.Name = "Status";
			columnStatus.DataSource = StatusChange.StatusEnumItems.GetStatusEnumItems();
			columnStatus.DisplayMember = "Display";
			columnStatus.ValueMember = "Value";
			columnStatus.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

			grdStatusChanges.Columns.Add(columnDate);
			grdStatusChanges.Columns.Add(columnStatus);
			this.dtpFrom.Value = DateTime.Today;
			this.dtpTo.Value = DateTime.Today.AddDays(1);
			grdStatusChanges.RowValidated += new DataGridViewCellEventHandler(grdStatusChanges_RowValidated);
			DoFilter();
		}

		protected override void OnLoad(EventArgs e) {
			base.OnLoad(e);
		}

		void grdStatusChanges_RowValidated(object sender, DataGridViewCellEventArgs e) {
			DataGridViewRow modifiedRow = grdStatusChanges.Rows[e.RowIndex];
		}

		private void btnFilter_Click(object sender, EventArgs e) {
			DoFilter();
		}

		private void DoFilter() {
			List<StatusChange> list = DataAccessLayer.GetStatusChanges(User.CurrentUser, dtpFrom.Value, dtpTo.Value);
			bindingList = new BindingList<StatusChange>(list);
			grdStatusChanges.DataSource = bindingList;
		}







		
	




	}
}